/*
 * Copyright (c) 2025 CAX Conversion Project
 */
package com.comac.ins.isfd.constant.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 调度类型（0-周期性任务，1-外部触发任务）
 *
 * @author hxloongs
 * @date 2024-10-12
 */
@AllArgsConstructor
@Getter
public enum IsfdDatasourceTaskSchedulingConfigTypeEnum {
    CYCLE(0, "周期性任务"),
    OUTER(1, "外部触发任务");

    private final Integer value;
    private final String desc;

    public static String getDescByValue(Integer value) {
        IsfdDatasourceTaskSchedulingConfigTypeEnum isfdDatasourceTaskSchedulingConfigTypeEnum = forValue(value);
        if (isfdDatasourceTaskSchedulingConfigTypeEnum == null) {
            return null;
        }
        return isfdDatasourceTaskSchedulingConfigTypeEnum.getDesc();
    }

    public static IsfdDatasourceTaskSchedulingConfigTypeEnum forValue(Integer value) {
        if (value == null) {
            return null;
        }
        for (IsfdDatasourceTaskSchedulingConfigTypeEnum isfdDatasourceTaskSchedulingConfigTypeEnum : IsfdDatasourceTaskSchedulingConfigTypeEnum.values()) {
            if (isfdDatasourceTaskSchedulingConfigTypeEnum.getValue().equals(value)) {
                return isfdDatasourceTaskSchedulingConfigTypeEnum;
            }
        }
        return null;
    }

    public static IsfdDatasourceTaskSchedulingConfigTypeEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (IsfdDatasourceTaskSchedulingConfigTypeEnum isfdDatasourceTaskSchedulingConfigTypeEnum : IsfdDatasourceTaskSchedulingConfigTypeEnum.values()) {
            if (desc.equals(isfdDatasourceTaskSchedulingConfigTypeEnum.getDesc())) {
                return isfdDatasourceTaskSchedulingConfigTypeEnum;
            }
        }
        return null;
    }
}
